package rack.lite.view

import rack.lite.view.Console as con
import rack.lite.model.AlunoDisciplinaDao
/**
 *
 * @author atila
 */
@Singleton class AlunoDisciplinaView {

   def menu() {
      def builder = new StringBuilder()
      builder.append("[c]riar relação Aluno_Disciplina\n")
      builder.append("[l]istar relação AlunoDisciplina\n")
      builder.append("[/sair][/quit][/exit][/clear]")
      println builder.toString()
   }

   def index() {
      def option
      while (true) {
         menu()
         print con.bash
         option = con.read.nextLine()
         switch (option) {
            case ["", "*", "l", "L"]:
               AlunoDisciplinaDao.instance.list()
               continue
            case ["/sair", "/quit", "/exit"]:
               return false
            case "/clear":
               con.clearConsole()
               continue
            default:
               println "Opção inválida."
               continue
         }
      }
   }
}

